﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WEB.Core.Controls;
using log4net;
using WEB.Core.Util;
using Ext.Net;
using WEB.BLL.Entities;
using WEB.BLL.Services;

namespace WEB.APP.Modules.System
{
    public partial class Screen : BasePage
    {
        public Screen()
            : base(SCREENS.LISTSCREENS,false)
        {

        }

        protected override void Page_Load(object sender, EventArgs e)
        {
            base.Page_Load(sender, e);
            grMain.ColumnModel.Columns[1].Editable = IsEdit;
        }

        protected void MainList_OnRefreshData(object sender, StoreRefreshDataEventArgs e)
        {
            try
            {
                ScreenService ScreenS = ScreenService.GetInstance();
                IList<ScreenEntity> lstScreen = ScreenS.LoadAllEx();
                if (lstScreen != null)
                {
                    stMain.DataSource = lstScreen;
                    stMain.DataBind();
                }
            }
            catch (Exception ex)
            {
                Notification(ex);
            }
        }

        [DirectMethod]
        public void QuickEdit(string ID, string Name)
        {
            if (IsEdit)
            {
                ScreenEntity ScreenE = new ScreenEntity();
                ScreenService ScreenS = ScreenService.GetInstance();
                ScreenE.ScreenId = ID;
                ScreenE.ScreenName = Name;
                ScreenS.UpdateName(ScreenE);
            }
            else
            {
                X.Msg.Alert("Notification", "You do not have permission edit.").Show();
                stMain.DataBind();
            }
        }
    }
}
